package com.xiaolun.single;

//饿汉式（静态变量）
public class Singleton2 {

    private Singleton2(){
    }

    private static final Singleton2 instance;

    //在静态代码块执行时，创建单例对象
    static {
        instance = new Singleton2();
    }
    public static Singleton2 getInstance(){
        return instance;
    }
}
